Linux Networking Internals 1 - Critical Data Structures

本系列是阅读《Linux Networking Internals》书籍的总结

《Linux Networking Internals》 是基于Linux解释network的书籍, 文章内容还是不错的.
另推荐一本书《Understanding the Linux Kernel》, 阅读本系列之前更加推荐之前的文章, 关于该文章的记录也会放在博客上.

Critical Data Structures

  • struct sk_buff
    存放packet的结构体
  • struct net_device
    linux kernel中指代网络设备的结构体
  • struct sock
    存放socket信息的结构体

sk_buff

Sock Buffer: sk_buff
包括以下内容:

  1. Layout
  2. General
  3. Feature-specific
  4. Management functions: skb_put, skb_push, skb_pull, skb_reserve

alloc_skb -> dev_alloc_skb

kfree_skb -> dev_kfree_skb

skb_reserve

net_device

net_device structure include:

  1. Configuration
  2. Statistics
  3. Device status
  4. List management
  5. Traffic management
  6. Feature specific
  7. Generic
  8. Function pointers (or VFT)

tips: ifconfig/route 通过 ioctl 系统调用来实现; ip/IPROUTE2 使用Netlink socket 来实现.